//
//  UserCertificateViewController.m
//  jinnengExam
//
//  Created by mac on 2020/8/28.
//  Copyright © 2020 jznrj. All rights reserved.
//

#import "UserCertificateViewController.h"
#import "PBFlatBarButtonItems.h"
@interface UserCertificateViewController ()

@end

@implementation UserCertificateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"个人证书";
     UINavigationBar * bar = self.navigationController.navigationBar;
    UIImage *bgImage = [ColorUtil navigationBarColor:[ColorUtil titleColor] BarSize:bar.frame alphe:1.0];
    [bar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];
    [bar setTintColor:[UIColor whiteColor]];
    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]}forState:UIControlStateNormal];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil]];
     
//     UIBarButtonItem *otherButton = [PBFlatBarButtonItems Title:@"添  加" Target:self selector:@selector(add)];
//     [self.navigationItem setRightBarButtonItem:otherButton];
    
    self.tabBarController.tabBar.frame = CGRectMake(0, 0, 0, 0);
    self.tabBarController.tabBar.hidden = YES;
    [self initView];
    [self registerJSFuntion];
}

-(void) viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = NO;
}

-(void) initView{
    [self.view addSubview:self.jznWebView];
    [self.jznWebView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.right.equalTo(self.view);
        make.top.equalTo(self.view);
         if (@available(iOS 11.0, *)) {

             make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
         } else {
             make.bottom.equalTo(self.view);
         }
     }];
     self.view.backgroundColor = [UIColor whiteColor];
    self.jznWebView.scrollView.bounces = NO;
    [self.jznWebView loadLocalFile:@"/ios_jinneng/userCertificate" type:@"html"];

}
-(void) registerJSFuntion{

}

- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
    [self getUserCertificate];
}

-(void) getUserCertificate{
    NSString *url = [NSString stringWithFormat:@"%@/certificate/findUserCertificate" ,[URLUtil hostName]];
    NSDictionary *params = @{@"userId":[NSString stringWithFormat:@"%d",self.loginDto.userId]};
    
    [JZNRequestUtil requestUrl:url requestParams:params success:^(DataResult *dataResult) {
        if(dataResult.code == 0){

            
            NSString *getData = [NSString stringWithFormat:@"getCertificateList(%@)",[dataResult.data mj_JSONString]];
            //[self.jznWebView stringByEvaluatingJavaScriptFromString: clear];
            [self.jznWebView evaluateJavaScript:getData completionHandler:nil];
        }else {
        }
    } failure:^(NSError *error) {
        
    }];
}

-(void) add{
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
